<?php 

$results =  $resultHandler->displayResults(1); 

						
echo '<div class="flightBoxHeader">
		<div class="headerheenreis">
			<span class="headerheen">Heenreis</span><br/>
			<span class="headerheendatum"> < '.$_SESSION['search']->getDepartureDate().' <span class="orangeArrow">></span> </span>
		</div>
		';
			if($_SESSION['search']->getReturnDate() != ""){
			echo '
			<div class="seperator"></div>
			<div class="headerterugreis">
				<span class="headerterug">Terugreis</span><br/>
				<span class="headerterugdatum"> <  '.$_SESSION['search']->getReturnDate().'  <span class="orangeArrow">></span></span>
			</div>';
		}
		echo '	
		<div class="seperator"></div>
		<div class="prijsPerVolwassene">
			<span class="prijsPerVol"><br/>Prijs per volwassene</span>
		</div>
</div>';
						
						
foreach($results as $ticket){
		echo'<div class="flightBox">
				<div class="flightBoxLeftOperator">
					<div class="carrierLogo">';
					//Vervangen in de db
						switch($ticket->operatingCarrier){
							case "Transavia":
								echo '<img class="carLogo"" src="http://www.voxius.nl/files/imagecache/consultant_page_big/logo_4.png" alt="transavia logo"/>';
								break;
							case "AF":
								echo '<img class="carLogo"  src="http://www.yourlogoresources.com/wp-content/uploads/2011/07/air-france-logo.jpg" alt="air france logo"/>';
								break;
							case "KL":
								echo '<img class="carLogo"  src="http://www.unie.nl/portals/1/Images/Logos/KLM.jpg" alt="klm logo"/>';
								break;
							case "QF":
								echo '<img class="carLogo"  src="http://www.pasra.nl/resources/1/logoQF.jpg" alt="Qantas logo"/>';
								break;
							case "SQ":
								echo '<img class="carLogo"  src="http://images.wikia.com/logopedia/images/f/fa/Singapore_Airlines.svg" alt="SQ logo"/>';
								break;
							case "CX":
								echo '<img class="carLogo"  src="http://www.antatour.com/file/image/2011/07/cathaypacific.jpg" alt="CX logo"/>';
								break;
							case "EK":
								echo '<img class="carLogo"  src="http://datecrown.nl/images/Emirates_Logo%5B1%5D.jpg" alt="CX logo"/>';
								break;
							case "LH":
								echo '<img class="carLogo" src="http://topnews.ae/images/Deutsche-Lufthansa-AG.jpg" alt="CX logo"/>';
								break;
							case "CI":
								echo '<img class="carLogo" src="http://t3.gstatic.com/images?q=tbn:ANd9GcR2CuRVoy_JCYYbmVh9Lu5JpRm06E2l8Dgstpy67l1eTF6cUDn1JA&t=1" alt="CX logo"/>';
								break;
							case "AY":
								echo '<img class="carLogo" src="http://clickairways.aero/Click-Airways-Logo.jpg" alt="CX logo"/>';
								break;
							case "FI":
								echo '<img class="carLogo" src="http://www.virtually-creative.com/projects/categories/identity/Icelandair_01.jpg" alt="FI logo"/>';
								break;
							case "AA":
								echo '<img class="carLogo" src="http://www.goodlogo.com/images/logos/american_airlines_logo_3070.gif" alt="AA logo"/>';
								break;
							case "US":
								echo '<img class="carLogo" src="http://images.wikia.com/logopedia/images/2/2c/Piedmont_Airlines_1980s.png" alt="Scandinavian  logo"/>';
								break;
							case "SK":
								echo '<img class="carLogo" src="http://t0.gstatic.com/images?q=tbn:ANd9GcQjqW8vWhU55d0jQgfeJdKQCDuxBDHjAeNA2OmpgneNCXoYJ17how&t=1" alt="CX logo"/>';
								break;
							case "AZ":
								echo '<img class="carLogo" src="http://logocompany.info/wp-content/uploads/2012/06/Alitalia-Logo.jpg" alt=" Alitalia-Compagnia Aerea Italiana logo"/>';
								break;
							default:
								echo $ticket->operatingCarrier;
						}
						
						// if($_SESSION['result'][$i]['deptStops'] != 0){
							// $deptStops = count($_SESSION['result'][$i]['deptStops'])  -1;
						 // }else{
							// $deptStops = 0;
						// }
						
						// if($_SESSION['result'][$i]['return']['deptStops'] != 0){
							// $retStops =  count($_SESSION['result'][$i]['return']['deptStops'])  -1;
						 // }else{
							// $retStops = 0;
						// }
					
					
					echo '</div>';
					echo '
					<div class="flightDetails">
						<a  id="'.$i.'" onclick="showPopup('.$i.')">
							<img class="flightDetailsImg" src="images/details.png" alt="details" />Vlucht details
						</a>
					</div>
				</div>
				<div class="flightBoxFlightInfo">
					<div class="heenreis">
						<div class="heengegevens">
						';
					
						$fromTime = $ticket->flights_outbound[0]['fromDateTime']->format("h:i");
						$dp = count($ticket->flights_outbound)  -1;	
						$toTime = $ticket->flights_outbound[$dp]['toDateTime']->format("h:i");
					//	$lastElement = $ticket->flights_outbound[$dp]->toDateTime;
					//	$toTime = $ticket->flights_outbound[$dp]['fromDateTime']->format("h:i");
					
				//		$ticket->flights_outbound[0]['toDateTime']
				echo '
							<div class="timeAirport"><b>'.$fromTime.'</b> '.$ticket->flights_outbound[0]['fromIATA'].' - <b> '.$toTime.' </b> '.$ticket->flights_outbound[$dp]['toIATA'].' </div>
							<div class="heenStops"> '. $dp  .' Tussenstop: <span class="whereStop">';
							
							for($x = 1; $x <= $dp; $x++){	
								if($x == $dp){
									echo $ticket->flights_outbound[$x]['fromIATA'];		
								}else{
									echo $ticket->flights_outbound[$x]['fromIATA'].',';		
								}
										
							}		
		
							echo 
							'</span></div>
							<div class="travelTime"> '.$ticket->journeyTime.'</div>
						</div>
					</div>
						';
						
						$fromTime = $ticket->flights_inbound[0]['fromDateTime']->format("h:i");
						$dp = count($ticket->flights_inbound)  -1;	
						$toTime = $ticket->flights_inbound[$dp]['toDateTime']->format("h:i");
					
					echo '
					<div class="flightInfoSeperator"></div>
					<div class="heenreis">
						<div class="teruggegevens">
							<div class="timeAirport"><b>'.$fromTime.'</b> '.$ticket->flights_inbound[0]['fromIATA'].' - <b> '.$toTime.' </b> '.$ticket->flights_inbound[$dp]['toIATA'] .'</div>
							<div class="heenStops"> '.$dp .' Tussenstop: <span class="whereStop">';
								$totalTime = $ticket->flights_inbound[0]['fromDateTime']->format("h:i");
							
								$time = new DateTime();
								for($x = 1; $x <= $dp; $x++){	
									if($x == $dp){
										echo $ticket->flights_inbound[$x]['fromIATA'];		
									}else{
										echo $ticket->flights_inbound[$x]['fromIATA'].',';
									}
										$departureTime = new DateTime($ticket->flights_inbound[$x]['fromDateTime']);
										$arrivalTime = new DateTime($ticket->flights_inbound[$x]['toDateTime']);
										$time->add($departureTime->diff($arrivalTime));								
								}		
								print_r($time->format("h:i"));
								echo
							'</span></div>
							<div class="travelTime">'.  (int)$_SESSION['result'][$i]['return']['flightTime']['hours'].'.' .$_SESSION['result'][$i]['return']['flightTime']['min'].' uur</div>
						</div>
					</div>';
					
					
					echo '
					<div class="flightInfoSeperator"></div>
					<div class="book">
						<div class="bookingPrice">&euro; '.$ticket->totalPrice.'</div>
						<a href="'.$ticket->url.'"><button width="20"  name="submit" value="" class="bookingButton">Boeken <span style=" float:right;">></span></button></a>
					</div>
					<div class="flightBoxFooterSeperator"></div>
					<div class="flightBoxFooter">
						<div class="flightBoxFooterInfo">Ook beschikbaar bij: <a href="#" class="alsoAvaible" >Transavia &euro; 3444</a>   <a href="#" class="alsoAvaible">Transavia &euro; 3444</a>   <a href="#" class="alsoAvaible">Transavia &euro; 3444</a> </div>
					</div>
				</div>
			</div>';
}